


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文章</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiAdmin.std/src/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiAdmin.std/src/layuiadmin/style/admin.css" media="all">
</head>
<body>


<div class="layui-fluid">
    <div class="layui-row layui-col-space15">

        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">

                    <div class="layui-form">

                        <input type="hidden" id="id" name="id" value="{$entry.id}" />

                        <div class="layui-form-item">
                            <label class="layui-form-label">分类名称：</label>
                            <div class="layui-input-block">
                                <input type="text" id="title" name="title" value="{$entry.title}"
                                       lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">排序值：</label>
                            <div class="layui-input-block">
                                <input type="text" id="idx" name="idx" value="{$entry.idx}"
                                       lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="btn_save" id="btn_save">保存编辑</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/layuiAdmin.std/src/layuiadmin/layui/layui.js"></script>
<script>
    var tree;
    var layer;
    var util;
    var select;
    var $;
    var form;
    var layedit;

    function save(field) {
        $('#btn_save').hide()
        $.ajax({
            url: 'save',
            type: 'POST',
            data: field,
            dataType: 'json',
            success: function (data) {
                if (data.code == '0') {
                    layer.msg('保存成功', { icon: 1, time: 2000 }, function () {
                        //parent.location.reload()
                        parent.layer.closeAll()
                        parent.$('#btnSearch').click();

                        $('#btn_save').show()
                    });

                } else {
                    layer.msg(data.msg, { icon: 5, time: 2000 });

                    $('#btn_save').show()
                }
            }
        });
    }


    layui.config({
        base: '/static/layuiAdmin.std/src/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tree', 'util', 'customSelect', 'layedit'], function(){
        tree = layui.tree
        layer = layui.layer
        util = layui.util
        select = layui.customSelect
        $ = layui.$
        form = layui.form
        layedit = layui.layedit;

        form.on('submit(btn_save)', function(obj){

            save(obj.field)

        });
    });
</script>
</body>
</html>